#!/bin/bash -e

function info() {
echo Usage: `basename $0` 'mpileup'
exit 1
}

while getopts  ":p:f:i:" opt; do
    case  $opt  in
        p) out_prefix=$OPTARG;;
        f) suffix=$OPTARG;;
        i) interval=$OPTARG;;
        *) info;;
    esac
done
shift $(($OPTIND - 1))


if [ $# -lt 1 ]; then info; fi

. $var


# SNP calling with VarScan
$java_run/varscan mpileup2snp $1 \
--min-coverage 4 \
--min-reads2 1 \
--min-avg-qual 20 \
--min-var-freq 0.001 \
--min-freq-for-hom 0.1 \
--strand-filter 0 \
--p-value 0.9 \
--output-vcf 1 > $out_prefix.varscan.snp.vcf

# INDEL calling with VarScan
$java_run/varscan mpileup2indel $1 \
--min-coverage 4 \
--min-reads2 1 \
--min-avg-qual 15 \
--min-var-freq 0.0001 \
--min-freq-for-hom 0.1 \
--p-value 0.9 \
--strand-filter 0 \
--output-vcf 1 > $out_prefix.varscan.indel.vcf

. $cmd_done

